package com.ynny.demo10;
import java.util.ArrayList;
import java.util.List;
public class StudentsTest {
    public static void main(String[]args){
        ArrayList<Students> list=new ArrayList<>();
        Students s1=new Students();
        s1.setName("张三");
        s1.setId(1);

        Students s2 = new Students();
        s2.setName("李四");
        s2.setId(2);

        list.add(s1);
        list.add(s2);
        System.out.println(list);


        for (int i = 0; i < list.size(); i++) {
            Students student = list.get(i);
            System.out.println(student.getId() + "-" + student.getName());
        }
        for (int i = 0; i < list.size(); i++) {
            Students student = list.get(i);
            if (student.getName().equals("张三")) ;
            student.setName("张三丰");
        }
        System.out.println(list);
        for (int i = 0; i <list.size() ; i++) {
            Students student = list.get(i);
            if (student.getName().equals("李四")) ;
            list.remove(student);

        }

        for (int i = 0; i < list.size(); i++) {
            Students student = list.get(i);
            System.out.println(student.getId() + "-" + student.getName());
        }
    }
}


